<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%@include file="taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <style>
        form{
            margin-top: 20px;
        }

        form div {
            margin-right: 22px;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <form class="form-inline" action="/emp/getAll" method="post">
                <div class="form-group">
                    <label>员工姓名</label>
                    <input type="text" style="width: 200px" class="form-control" id="ename" name="ename">
                </div>
                <div class="form-group">
                    <label>日期:</label>
                    <input type="date" class="form-control" name="star" >至
                    <input type="date" class="form-control" name="end" >
                </div>
                <div class="form-group">
                    <label class="radio-inline">
                        <input type="radio" name="esex" value="男"> 男
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="esex" value="女"> 女
                    </label>
                </div>
                <div class="form-group">
                    <select class="form-control" name="dno" id="dno">
                        <option value="0">请选择部门</option>
                    </select>
                </div>
                <button type="submit" class="btn btn-default">查询</button>
            </form>
        </div>
        <div class="col-md-10 col-md-offset-1">
            <table class="table table-hover table-bordered">
                <thead>
                    <tr>
                        <td>员工编号</td>
                        <td>员工姓名</td>
                        <td>员工性别</td>
                        <td>员工薪资</td>
                        <td>员工密码</td>
                        <td>员工部门</td>
                        <td>员工生日</td>
                        <td>操作</td>
                    </tr>
                </thead>

                <tbody>
                    <c:forEach items="${info.list}" var="e">
                        <tr>
                            <td>${e.eno}</td>
                            <td>${e.ename}</td>
                            <td>${e.esex}</td>
                            <td>${e.salary}</td>
                            <td>${e.pwd}</td>
                            <td>${e.dept.dname}</td>
                            <td><fmt:formatDate value="${e.birthday}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                            <td>操作</td>
                        </tr>
                    </c:forEach>
                </tbody>

                <tfoot>
                    <tr align="center">
                        <td colspan="8">
                            <nav aria-label="Page navigation">
                                <ul class="pagination">
                                    <li>
                                        <a href="/emp/getAll?pageNum=1" aria-label="Previous">
                                            <span aria-hidden="true">首页</span>
                                        </a>
                                    </li>

                                    <li>
                                        <a href="/emp/getAll?pageNum=${info.prePage}" aria-label="Previous">
                                            <span aria-hidden="true">&laquo;</span>
                                        </a>
                                    </li>
                                    <c:forEach items="${info.navigatepageNums}" var="i">
                                        <li ${info.pageNum==i?"class='active'":""}><a href="/emp/getAll?pageNum=${i}">${i}</a></li>
                                    </c:forEach>
                                    <li>
                                        <a href="/emp/getAll?pageNum=${info.nextPage}" aria-label="Next">
                                            <span aria-hidden="true">&raquo;</span>
                                        </a>
                                    </li>

                                    <li>
                                        <a href="/emp/getAll?pageNum=${info.pages}" aria-label="Next">
                                            <span aria-hidden="true">尾页</span>
                                        </a>
                                    </li>

                                </ul>
                            </nav>
                        </td>
                    </tr>
                </tfoot>
            </table>
        </div>

    </div>
</div>

<
<script>
    $(function () {
        $.ajax({
            url:"/dept/getAllByDept",
            type:"get",
            dataType:"json",
            success:function (result) {
                for (let i in result){
                    $("#dno").append("<option value='"+result[i].dno+"'>"+result[i].dname+"</option>")
                }
            }
        })
    })

    
</script>

</body>
</html>